CONTENTS | INDEX | PREV | NEXT
 strftime

 NAME
  strftime - convert broken down time into a string according to a format.

 SYNOPSIS
  size_t len = strftime(buf, max, fmt, tm)
  char *buf;
  size_t max;
  const char *fmt;
  const struct tm *tm;

 FUNCTION
  strftime formats a broken down time into a buffer according to
  a format string fmt.  The fmt string looks like a the format for
  a printf except with different control definitions:

  %%  - a literal '%' character
  %a  - The locale's abbreviated name for the day of week
  %A  - The locale's full name for the day of week
  %b  - The locale's abbr. name for the month
  %B  - The locale's full name for the month
  %c  - The locale's default representation for the date & time (ctime)
  %d  - The day of the month 01-31
  %H  - The hour 00-23  (24 hour time)
  %I  - The hour 01-12  (12 hour time)
  %j  - The day in the year 001-366
  %m  - The month 01-12
  %M  - The minute 00-59
  %p  - Indication of morning or afternoon.  In the US: "AM" or "PM"
  %S  - The second 00-59
  %U  - The week of the year 00-53, sunday is the first day in a week
  %w  - The day of the week 0-6, sunday=0  (standard)
  %W  - The day of the week 0-6, monday=0
  %x  - The locale's default representation for the date only
  %X  - The locale's default representation for the time only
  %y  - The year mod 100 (00-99)
  %Y  - The full year (e.g. 1990)
  %Z  - The name of the locale's time zone, nothing if unknown

  The number of characters written to the string is returned, or 0
  if the formatted string exceeds the buffer size.

 WARNING
  There must be at least max + 1 bytes in buf or unexpected memory
  might get overwritten.

 EXAMPLE
  #include <stdio.h>
  #include <time.h>

  main()
  {
      time_t t = time(NULL);
      struct tm *tp = localtime(&t);
      char buf[256];

      strftime(buf, sizeof(buf) - 1, "Now is %A %d %B %Y  %X", tp);
      puts(buf);

      return(0);
  }

 INPUTS
  char *buf;      buffer to write formatted string into
  size_t max;     maximum size of buffer - 1
  char *fmt;      format string
  struct tm *tm;  broken down time

 RESULTS
  size_t len;     length of formatted string in buffer or 0
              if the maximum was exceeded.

 SEE ALSO
  time, localtime, asctime, ctime, clock